home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 176-200 / disk_178 / cosmic / main.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  13KB  |  530 lines

  1. #include <functions.h>
  2. #include <graphics/gfxbase.h>
  3. #include <graphics/rastport.h>
  4. #include <intuition/intuitionbase.h>
  5. #include <stdio.h>
  6. #include <ctype.h>
  7. #include "defs.h"
  8.  
  9. #define ABOX(x1,y1,x2,y2) SetAPen(ConPort,GREENPEN);RectFill(ConPort,(long) 10*x1,(long) 5*y1+5,(long) 10*x2+9,(long) 5*y2+9)
  10. #define EBOX(x1,y1,x2,y2) SetAPen(ConPort,BLACKPEN);RectFill(ConPort,(long) 10*x1,(long) 5*y1+5,(long) 10*x2+9,(long) 5*y2+9)
  11.  
  12. struct NewScreen NScreen =
  13.   {
  14.   0,0,640,200,
  15.   3,
  16.   GREENPEN,WHITEPEN,
  17.   HIRES,
  18.   CUSTOMSCREEN,
  19.   NULL,
  20.   NULL,
  21.   NULL,
  22.   NULL
  23.   };
  24.  
  25. struct NewWindow NWindow =
  26.   {
  27.   0,0,
  28.   640,200,
  29.   GREENPEN,WHITEPEN,
  30.   VANILLAKEY|MOUSEBUTTONS,
  31.   BORDERLESS|BACKDROP|SIMPLE_REFRESH|NOCAREREFRESH|RMBTRAP|ACTIVATE,
  32.   NULL,
  33.   NULL,
  34.   NULL,
  35.   NULL,
  36.   NULL,
  37.   640,200,
  38.   640,200,
  39.   CUSTOMSCREEN
  40.   };
  41.  
  42. USHORT CrossPointer[]=
  43.   {
  44.   0,0,
  45.   0x0800,0x0000,
  46.   0x0800,0x0000,
  47.   0x0800,0x0000,
  48.   0x0000,0x0000,
  49.   0xe380,0x0000,
  50.   0x0000,0x0000,
  51.   0x0800,0x0000,
  52.   0x0800,0x0000,
  53.   0x0800,0x0000,
  54.   0,0
  55.   };
  56. struct NStar star[STARNO];
  57. struct NTask task[PLAYERNO][TASKNO+1];
  58. struct NCommData CommData[PLAYERNO];
  59. struct NGeneral general;
  60. struct Screen *ConScreen=NULL;
  61. struct Window *ConWindow=NULL;
  62. struct IntuitionBase *IntuitionBase;
  63. struct GfxBase *GfxBase;
  64. struct RastPort *ConPort;
  65.  
  66. int growth[PLANETNO]={3,5,7,8,7,6,4,2};
  67.  
  68. int fline;
  69. int mode=-1,mode2=0,mode3=0;
  70. int file=-1;
  71. int waittime=-1;
  72.  
  73. struct NShip ship[SHIPNO]=
  74.   {
  75.     {
  76.     "Clearer",/* char name[STRLENGTH];*/
  77.     3, /*int size;*/
  78.     0, /*int capacity;*/
  79.     0, /*int hyprange;*/
  80.     0, /*int hypspeed;*/
  81.     1, /*int speed;*/
  82.     1, /*int attack;*/
  83.     20, /*int attackno;*/
  84.     4, /*int shields;*/
  85.     NOSPEC, /*int special;*/
  86.     100, /*int techcost;*/
  87.     620  /*int techlevel;*/
  88.     },
  89.     {
  90.     "UltraStinger",/* char name[STRLENGTH];*/
  91.     1, /*int size;*/
  92.     0, /*int capacity;*/
  93.     50, /*int hyprange;*/
  94.     50, /*int hypspeed;*/
  95.     3, /*int speed;*/
  96.     7, /*int attack;*/
  97.     1, /*int attackno;*/
  98.     4, /*int shields;*/
  99.     NOSPEC, /*int special;*/
  100.     60,  /*int techcost;*/
  101.     800  /*int techlevel;*/
  102.     },
  103.     {
  104.     "Stinger",/* char name[STRLENGTH];*/
  105.     1, /*int size;*/
  106.     0, /*int capacity;*/
  107.     0, /*int hyprange;*/
  108.     0, /*int hypspeed;*/
  109.     3, /*int speed;*/
  110.     7, /*int attack;*/
  111.     1, /*int attackno;*/
  112.     2, /*int shields;*/
  113.     FASTEJECTABLE, /*int special;*/
  114.     25, /*int techcost;*/
  115.     150  /*int techlevel;*/
  116.     },
  117.     {
  118.     "Light Cruiser",/* char name[STRLENGTH];*/
  119.     5, /*int size;*/
  120.     0, /*int capacity;*/
  121.     6, /*int hyprange;*/
  122.     1, /*int hypspeed;*/
  123.     5, /*int speed;*/
  124.     10, /*int attack;*/
  125.     1, /*int attackno;*/
  126.     10, /*int shields;*/
  127.     NOSPEC, /*int special;*/
  128.     100, /*int techcost;*/
  129.     100  /*int techlevel;*/
  130.     },
  131.     {
  132.     "Space Cannon",/* char name[STRLENGTH];*/
  133.     10, /*int size;*/
  134.     0, /*int capacity;*/
  135.     0, /*int hyprange;*/
  136.     0, /*int hypspeed;*/
  137.     4, /*int speed;*/
  138.     40, /*int attack;*/
  139.     1, /*int attackno;*/
  140.     0, /*int shields;*/
  141.     NOSPEC, /*int special;*/
  142.     120, /*int techcost;*/
  143.     550  /*int techlevel;*/
  144.     },
  145.     {
  146.     "Destroyer",/* char name[STRLENGTH];*/
  147.     12, /*int size;*/
  148.     0, /*int capacity;*/
  149.     9, /*int hyprange;*/
  150.     2, /*int hypspeed;*/
  151.     6, /*int speed;*/
  152.     18, /*int attack;*/
  153.     1, /*int attackno;*/
  154.     10, /*int shields;*/
  155.     NOSPEC, /*int special;*/
  156.     110, /*int techcost;*/
  157.     310  /*int techlevel;*/
  158.     },
  159.     {
  160.     "Battleship",/* char name[STRLENGTH];*/
  161.     25, /*int size;*/
  162.     3, /*int capacity;*/
  163.     8, /*int hyprange;*/
  164.     2, /*int hypspeed;*/
  165.     6, /*int speed;*/
  166.     15, /*int attack;*/
  167.     3, /*int attackno;*/
  168.     18, /*int shields;*/
  169.     FASTEJECTER, /*int special;*/
  170.     150, /*int techcost;*/
  171.     450  /*int techlevel;*/
  172.     },
  173.     {
  174.     "Battlestar",/* char name[STRLENGTH];*/
  175.     950, /*int size;*/
  176.     100, /*int capacity;*/
  177.     9, /*int hyprange;*/
  178.     1, /*int hypspeed;*/
  179.     8, /*int speed;*/
  180.     30, /*int attack;*/
  181.     15, /*int attackno;*/
  182.     40, /*int shields;*/
  183.     FASTEJECTER, /*int special;*/
  184.     900, /*int techcost;*/
  185.     950  /*int techlevel;*/
  186.     },
  187.     {
  188.     "HeavyCruiser",/* char name[STRLENGTH];*/
  189.     8, /*int size;*/
  190.     0, /*int capacity;*/
  191.     8, /*int hyprange;*/
  192.     1, /*int hypspeed;*/
  193.     7, /*int speed;*/
  194.     15, /*int attack;*/
  195.     1, /*int attackno;*/
  196.     14, /*int shields;*/
  197.     NOSPEC, /*int special;*/
  198.     120, /*int techcost;*/
  199.     220  /*int techlevel;*/
  200.     },
  201.     {
  202.     "Mothership",/* char name[STRLENGTH];*/
  203.     100, /*int size;*/
  204.     20, /*int capacity;*/
  205.     11, /*int hyprange;*/
  206.     1, /*int hypspeed;*/
  207.     6, /*int speed;*/
  208.     12, /*int attack;*/
  209.     2, /*int attackno;*/
  210.     24, /*int shields;*/
  211.     NOSPEC, /*int special;*/
  212.     230, /*int techcost;*/
  213.     620  /*int techlevel;*/
  214.     },
  215.     {
  216.     "Satellite",/* char name[STRLENGTH];*/
  217.     2000, /*int size;*/
  218.     0, /*int capacity;*/
  219.     0, /*int hyprange;*/
  220.     0, /*int hypspeed;*/
  221.     9, /*int speed;*/
  222.     12, /*int attack;*/
  223.     1, /*int attackno;*/
  224.     6, /*int shields;*/
  225.     NOSPEC, /*int special;*/
  226.     20, /*int techcost;*/
  227.     660  /*int techlevel;*/
  228.     },
  229.     {
  230.     "Trans III",/* char name[STRLENGTH];*/
  231.     20, /*int size;*/
  232.     8, /*int capacity;*/
  233.     9, /*int hyprange;*/
  234.     2, /*int hypspeed;*/
  235.     10, /*int speed;*/
  236.     0, /*int attack;*/
  237.     0, /*int attackno;*/
  238.     6, /*int shields;*/
  239.     NOSPEC, /*int special;*/
  240.     100, /*int techcost;*/
  241.     360  /*int techlevel;*/
  242.     },
  243.     {
  244.     "UltraTrans",/* char name[STRLENGTH];*/
  245.     40, /*int size;*/
  246.     30, /*int capacity;*/
  247.     50, /*int hyprange;*/
  248.     4, /*int hypspeed;*/
  249.     10, /*int speed;*/
  250.     0, /*int attack;*/
  251.     0, /*int attackno;*/
  252.     8, /*int shields;*/
  253.     NOSPEC, /*int special;*/
  254.     160, /*int techcost;*/
  255.     900  /*int techlevel;*/
  256.     },
  257.     {
  258.     "Glitter",/* char name[STRLENGTH];*/
  259.     20, /*int size;*/
  260.     19, /*int capacity;*/
  261.     0, /*int hyprange;*/
  262.     0, /*int hypspeed;*/
  263.     10, /*int speed;*/
  264.     0, /*int attack;*/
  265.     0, /*int attackno;*/
  266.     0, /*int shields;*/
  267.     NOSPEC, /*int special;*/
  268.     10, /*int techcost;*/
  269.     420  /*int techlevel;*/
  270.     },
  271.     {
  272.     "Scout",/* char name[STRLENGTH];*/
  273.     2, /*int size;*/
  274.     0, /*int capacity;*/
  275.     11, /*int hyprange;*/
  276.     3, /*int hypspeed;*/
  277.     10, /*int speed;*/
  278.     0, /*int attack;*/
  279.     0, /*int attackno;*/
  280.     6, /*int shields;*/
  281.     NOSPEC, /*int special;*/
  282.     50, /*int techcost;*/
  283.     180  /*int techlevel;*/
  284.     },
  285.     {
  286.     "Transporter",/* char name[STRLENGTH];*/
  287.     10, /*int size;*/
  288.     4, /*int capacity;*/
  289.     4, /*int hyprange;*/
  290.     1, /*int hypspeed;*/
  291.     10, /*int speed;*/
  292.     0, /*int attack;*/
  293.     0, /*int attackno;*/
  294.     6, /*int shields;*/
  295.     NOSPEC, /*int special;*/
  296.     40, /*int techcost;*/
  297.     50  /*int techlevel;*/
  298.     },
  299.     {
  300.     "Spy Sat",/* char name[STRLENGTH];*/
  301.     1, /*int size;*/
  302.     0, /*int capacity;*/
  303.     9, /*int hyprange;*/
  304.     1, /*int hypspeed;*/
  305.     10, /*int speed;*/
  306.     0, /*int attack;*/
  307.     0, /*int attackno;*/
  308.     70, /*int shields;*/
  309.     NOSPEC, /*int special;*/
  310.     280, /*int techcost;*/
  311.     750  /*int techlevel;*/
  312.     },
  313.     {
  314.     "Torpedo",/* char name[STRLENGTH];*/
  315.     1, /*int size;*/
  316.     0, /*int capacity;*/
  317.     0, /*int hyprange;*/
  318.     0, /*int hypspeed;*/
  319.     1, /*int speed;*/
  320.     25, /*int attack;*/
  321.     1, /*int attackno;*/
  322.     0, /*int shields;*/
  323.     KAMIKAZE|FASTEJECTABLE, /*int special;*/
  324.     15, /*int techcost;*/
  325.     240 /*int techlevel;*/
  326.     },
  327.     {
  328.     "Pirate",/* char name[STRLENGTH];*/
  329.     10, /*int size;*/
  330.     3, /*int capacity;*/
  331.     9, /*int hyprange;*/
  332.     2, /*int hypspeed;*/
  333.     5, /*int speed;*/
  334.     6, /*int attack;*/
  335.     3, /*int attackno;*/
  336.     14, /*int shields;*/
  337.     NOSPEC, /*int special;*/
  338.     180, /*int techcost;*/
  339.     370 /*int techlevel;*/
  340.     },
  341.     {
  342.     "Carrier",/* char name[STRLENGTH];*/
  343.     30, /*int size;*/
  344.     5, /*int capacity;*/
  345.     7, /*int hyprange;*/
  346.     1, /*int hypspeed;*/
  347.     10, /*int speed;*/
  348.     0, /*int attack;*/
  349.     0, /*int attackno;*/
  350.     28, /*int shields;*/
  351.     FASTEJECTER, /*int special;*/
  352.     100, /*int techcost;*/
  353.     430 /*int techlevel;*/
  354.     },
  355.     {
  356.     "Q-Bomb",/* char name[STRLENGTH];*/
  357.     30, /*int size;*/
  358.     0, /*int capacity;*/
  359.     0, /*int hyprange;*/
  360.     0, /*int hypspeed;*/
  361.     0, /*int speed;*/
  362.     0, /*int attack;*/
  363.     0, /*int attackno;*/
  364.     0, /*int shields;*/
  365.     STARKILLER, /*int special;*/
  366.     350,/*int techcost;*/
  367.     950/*int techlevel;*/
  368.     },
  369.     {
  370.     "Trans II",/* char name[STRLENGTH];*/
  371.     10, /*int size;*/
  372.     4, /*int capacity;*/
  373.     9, /*int hyprange;*/
  374.     1, /*int hypspeed;*/
  375.     0, /*int speed;*/
  376.     0, /*int attack;*/
  377.     0, /*int attackno;*/
  378.     6, /*int shields;*/
  379.     NOSPEC, /*int special;*/
  380.     70, /*int techcost;*/
  381.     210 /*int techlevel;*/
  382.     },
  383.     {
  384.     "",/* char name[STRLENGTH];*/
  385.     1, /*int size;*/
  386.     0, /*int capacity;*/
  387.     0, /*int hyprange;*/
  388.     0, /*int hypspeed;*/
  389.     0, /*int speed;*/
  390.     0, /*int attack;*/
  391.     0, /*int attackno;*/
  392.     0, /*int shields;*/
  393.     NOTPROD, /*int special;*/
  394.     1000, /*int techcost;*/
  395.     1000/*int techlevel;*/
  396.     },
  397.     {
  398.     "",/* char name[STRLENGTH];*/
  399.     1, /*int size;*/
  400.     0, /*int capacity;*/
  401.     0, /*int hyprange;*/
  402.     0, /*int hypspeed;*/
  403.     0, /*int speed;*/
  404.     0, /*int attack;*/
  405.     0, /*int attackno;*/
  406.     0, /*int shields;*/
  407.     NOTPROD, /*int special;*/
  408.     1000, /*int techcost;*/
  409.     1000/*int techlevel;*/
  410.     },
  411.     {
  412.     "",/* char name[STRLENGTH];*/
  413.     1, /*int size;*/
  414.     0, /*int capacity;*/
  415.     0, /*int hyprange;*/
  416.     0, /*int hypspeed;*/
  417.     0, /*int speed;*/
  418.     0, /*int attack;*/
  419.     0, /*int attackno;*/
  420.     0, /*int shields;*/
  421.     NOTPROD, /*int special;*/
  422.     1000, /*int techcost;*/
  423.     1000/*int techlevel;*/
  424.     },
  425.     {
  426.     "Ore Unit",/* char name[STRLENGTH];*/
  427.     1, /*int size;*/
  428.     0, /*int capacity;*/
  429.     0, /*int hyprange;*/
  430.     0, /*int hypspeed;*/
  431.     10, /*int speed;*/
  432.     0, /*int attack;*/
  433.     0, /*int attackno;*/
  434.     0, /*int shields;*/
  435.     NOTPROD, /*int special;*/
  436.     MCOST, /*int techcost;*/
  437.     0  /*int techlevel;*/
  438.     },
  439.     {
  440.     "Pop Unit",/* char name[STRLENGTH];*/
  441.     1, /*int size;*/
  442.     0, /*int capacity;*/
  443.     0, /*int hyprange;*/
  444.     0, /*int hypspeed;*/
  445.     10, /*int speed;*/
  446.     0, /*int attack;*/
  447.     0, /*int attackno;*/
  448.     0, /*int shields;*/
  449.     NOTPROD, /*int special;*/
  450.     20, /*int techcost;*/
  451.     0   /*int techlevel;*/
  452.     }
  453.   };
  454.  
  455. main()
  456.   {
  457.   /* Opening Libs */
  458.   IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",LIBRARY_VERSION);
  459.   if(IntuitionBase==NULL) cleanup("Unable to open intuition.library");
  460.   GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",LIBRARY_VERSION);
  461.   if (GfxBase==NULL) cleanup("Unable to open graphics.library");
  462.   /* Opening Screen */
  463.   ConScreen=(struct Screen *) OpenScreen(&NScreen);
  464.   if (ConScreen==NULL) cleanup("Unable to open conscreen");
  465.   ScreenToFront(ConScreen);
  466.   ShowTitle(ConScreen,FALSE);
  467.   SetRGB4(&(ConScreen->ViewPort),BLACKPEN, 0L, 0L, 0L);    /* Black  */
  468.   SetRGB4(&(ConScreen->ViewPort),WHITEPEN,15L,15L,15L);    /* White  */
  469.   SetRGB4(&(ConScreen->ViewPort),GREENPEN, 5L,13L, 0L);    /* Green  */
  470.   SetRGB4(&(ConScreen->ViewPort),OTHERPEN,15L,12L, 0L);    /* Orange */
  471.   SetRGB4(&(ConScreen->ViewPort),PLAYERPEN(0),15L, 2L, 0L);/* Red    */
  472.   SetRGB4(&(ConScreen->ViewPort),PLAYERPEN(1), 7L, 9L,15L);/* Blue   */
  473.   SetRGB4(&(ConScreen->ViewPort),PLAYERPEN(2),15L,15L, 2L);/* Yellow */
  474.   SetRGB4(&(ConScreen->ViewPort),PLAYERPEN(3), 0L,15L, 2L);/* Full Green */
  475.   SetRGB4(&(ConScreen->ViewPort),SPRITEPEN(0), 0L, 0L, 0L);/* Black  */
  476.   SetRGB4(&(ConScreen->ViewPort),SPRITEPEN(1), 5L,13L, 0L);/* Green  */
  477.   SetRGB4(&(ConScreen->ViewPort),SPRITEPEN(2),15L,15L,15L);/* White  */
  478.   SetRGB4(&(ConScreen->ViewPort),SPRITEPEN(3),15L,12L, 0L);/* Orange */
  479.   NWindow.Screen=ConScreen;
  480.   ConWindow=(struct Window *) OpenWindow(&NWindow);
  481.   if(ConWindow==NULL) cleanup("Unable to open ConWindow");
  482.   SetPointer(ConWindow,CrossPointer,9L,9L,-5L,-5L);
  483.   ConPort=ConWindow->RPort;
  484.   title();
  485.   conquest();
  486.   cleanup("OK.");
  487.   }
  488. cleanup(str)
  489. char *str;
  490.   {
  491.   puts(str);
  492.   if (file!=-1) close(file);
  493.   if (ConWindow) CloseWindow(ConWindow);
  494.   if (ConScreen) CloseScreen(ConScreen);
  495.   if (GfxBase) CloseLibrary(GfxBase);
  496.   if (IntuitionBase) CloseLibrary(IntuitionBase);
  497.   exit(1);
  498.   }
  499. title()
  500.   {
  501.   Move(ConPort,232L,10L);
  502.   Text(ConPort,"by",2L);
  503.   ABOX( 8, 0,15,15);
  504.   EBOX(10, 2,15,13);
  505.   ABOX(18, 8,25,15);
  506.   EBOX(20,10,23,13);
  507.   ABOX(24,16,25,16);
  508.   ABOX(28, 7,29,15);
  509.   ABOX(30, 8,33, 9);
  510.   ABOX(36, 2,37,15);
  511.   ABOX(38,14,39,15);
  512.   ABOX( 0,20, 7,35);
  513.   EBOX( 2,22, 7,33);
  514.   ABOX( 2,26, 5,27);
  515.   ABOX(10,28,17,35);
  516.   EBOX(12,30,15,33);
  517.   ABOX(16,22,17,27);
  518.   ABOX(20,27,21,27);
  519.   ABOX(20,28,29,35);
  520.   EBOX(22,30,23,35);
  521.   EBOX(26,30,27,35);
  522.   ABOX(32,28,39,35);
  523.   EBOX(34,30,37,33);
  524.   ABOX(38,36,39,36);
  525.   ABOX(42,28,47,35);
  526.   EBOX(44,30,45,35);
  527.   ABOX(42,27,43,27);
  528.   }
  529. #include "human.c"
  530.